<template>
	<view class="_tbody">
		<view class="title">
			欢迎使用走访！
		</view>
		<view class="text">
			<text>请填写登录信息</text>
		</view>

		<u--form labelPosition="left">
			<u-form-item label="" prop="account">
				<u-input v-model="account" placeholder="请输入账号" shape="circle" clearable maxlength="11"/>
				<!-- placeholderStyle='color: #F5F5F5;' color="#999999" border="none" -->
			</u-form-item>
			<u-form-item label="" prop="password">
				<u-input v-model="password" placeholder="请输入密码" type="password" shape="circle" clearable />
			</u-form-item>
		</u--form>

		<u-button @click="sub" shape="circle" class="button">登录</u-button>
		<view class="phonenumber">
			<!-- <text @click="tophone">手机验证码登录</text> -->
		</view>
	</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				account: '',
				password: '',
			}
		},
		methods: {
			sub() {
	          if (!this.account) {
					this.toastMsg("请输入帐号");
					return;
				}

				if (!this.password) {
					this.toastMsg("请输入密码");
					return;
				}


				let obj = {};
				obj.account = this.account;
				obj.password = this.password;

				this.$api.post('/api/user/login', obj).then((res) => {
					
					if (res.code == 1) {
						uni.setStorageSync('token', res.data.userinfo.token)
						  uni.removeStorageSync('group_id')
						   uni.removeStorageSync('flag')
                        uni.setStorageSync('group_id', res.data.userinfo.group_id)
						this.LoadingMsg(res.msg);
						setTimeout(() => {
							uni.hideLoading();
							
							uni.switchTab({
								url: '../index/index'
							})
						}, 1500);
					} else {
						this.toastMsg(res.msg);
					}
				})





			
			}
		},
		onLoad() {}
	}
</script>

<style lang="scss" scoped>
	._tbody {
		margin:60rpx;
	}

	.title {
		font-size: 48rpx;
		margin-top: 16rpx;
		font-weight: 600;
		color: #333333;
		font-family: 'Source Han Sans CN-Medium';
	}

	.text {
		margin-top: 20rpx;
		margin-bottom: 120rpx;
	}

	._b {
		margin-top: 40rpx;
	}

	.button {
		margin-top: 60rpx;
		background-color: #0C68FD;
		color: #fff;
	}

	.phonenumber {
		text-align: center;
		margin-top: 20rpx;
		font-size: 24rpx;
		color: #666666;
	}
</style>
